/**********************************************************************
 * SailmiPIM - modular cross-platform feature rich internet client.
 * Copyright(C) 2006-2014  Georg Rudoy
 *
 * Distributed under the Boost Software License, Version 1.0.
 *(See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
 **********************************************************************/

#include "util.h"
#include <QShortcut>
#include <QWidget>
#include <QMetaMethod>
namespace SailmiPIM::Util
{
	void CreateShortcuts(const QList<QKeySequence>& shortcuts,
			const std::function<void()>& func, QWidget *parent)
	{
        for(const QKeySequence &sc : shortcuts){
            QShortcut *qShortcuts = new QShortcut(sc,(QObject*)parent);
            QObject::connect(qShortcuts,
                             &QShortcut::activated,
                             parent,
                             func);
        }
	}

	void CreateShortcuts(const QList<QKeySequence>& shortcuts,
			QObject *object, const char *metamethod, QWidget *parent)
	{
        //yzh
        for(const QKeySequence &sc : shortcuts){
            QShortcut *qShortcuts = new QShortcut(sc,(QObject*)parent);
            QObject::connect(qShortcuts,
                             SIGNAL(activated),
                             object,
                             SLOT(metamethod));
        }
	}
}
